@model List<DeathReportManagement.Models.DeathReport>
@{
    ViewData["Title"] = "死亡报告列表";
}

<div class="d-flex justify-content-between align-items-center mb-3">
    <h2>死亡报告列表</h2>
    <a asp-action="Create" class="btn btn-primary">创建新报告</a>
</div>

@if (Model.Count == 0)
{
    <div class="alert alert-info">
        暂无死亡报告数据
    </div>
}
else
{
    <div class="table-responsive">
        <table class="table table-striped">
            <thead>
                <tr>
                    <th>报告编号</th>
                    <th>死者姓名</th>
                    <th>性别</th>
                    <th>年龄</th>
                    <th>死亡时间</th>
                    <th>审核状态</th>
                    <th>上报状态</th>
                    <th>创建人</th>
                    <th>创建时间</th>
                    <th>操作</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var report in Model)
                {
                    <tr>
                        <td>@report.ReportNo</td>
                        <td>@report.DeceasedName</td>
                        <td>@report.Gender</td>
                        <td>@report.Age @report.AgeUnit</td>
                        <td>@report.DeathDateTime.ToString("yyyy-MM-dd HH:mm")</td>
                        <td>
                            @if (report.AuditStatus == DeathReportManagement.Models.AuditStatus.Pending)
                            {
                                <span class="badge bg-warning">待审核</span>
                            }
                            else
                            {
                                <span class="badge bg-success">已审核</span>
                            }
                        </td>
                        <td>
                            @switch (report.ReportStatus)
                            {
                                case DeathReportManagement.Models.ReportStatus.NotReported:
                                    <span class="badge bg-secondary">附联未上报</span>
                                    break;
                                case DeathReportManagement.Models.ReportStatus.SubReported:
                                    <span class="badge bg-info">附联已上报</span>
                                    break;
                                case DeathReportManagement.Models.ReportStatus.MainReported:
                                    <span class="badge bg-primary">主联已上报</span>
                                    break;
                            }
                        </td>
                        <td>@report.Creator.Name</td>
                        <td>@report.CreateTime.ToString("yyyy-MM-dd HH:mm")</td>
                        <td>
                            <div class="btn-group" role="group">
                                <a asp-action="Details" asp-route-id="@report.Id" class="btn btn-sm btn-outline-primary">查看</a>
                                @if (User.IsInRole("Admin") || (User.IsInRole("Doctor") && report.AuditStatus == DeathReportManagement.Models.AuditStatus.Pending))
                                {
                                    <a asp-action="Edit" asp-route-id="@report.Id" class="btn btn-sm btn-outline-secondary">编辑</a>
                                }
                                <a asp-action="Print" asp-route-id="@report.Id" class="btn btn-sm btn-outline-info" target="_blank">打印</a>
                            </div>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}